IF not EXISTS(SELECT 1 from master..sysdatabases WHERE name='download')
    CREATE DATABASE DOWNLOAD;
    GO
USE DOWNLOAD;
IF NOT EXISTS(SELECT 1 FROM SYSOBJECTS WHERE NAME = 'download' AND XTYPE ='U')
CREATE TABLE download
(
  id int identity(1,1) not null PRIMARY KEY,
  url varchar(512) not null,
  localfile varchar(256) not null,
  category varchar(50) not null,
  owner varchar(50) not null,
  status int not null default 0,
  url_rank int not null default 100,
  insert_time datetime not null default getdate(),
  done_time datetime null,
  schedule datetime null,
  message varchar(256),
)
GO
